<?php
use yii\helpers\Url;
 ?>
<link rel="stylesheet" href="/static/css/cart.css" />
<div class="p-main">
	<div class="container">
		<div class="row">
			<div class="box pay-box">
				<div class="box-head clearfix webfont">
					<h2 class="pull-left">
                        我的购物车
					</h2>
				</div>
				<div class="box-body">
					<table class="table table-condensed table-bordered table-striped table-hover">
						<thead>
						  <tr class="th" style="font-size:20px;color:greed">
							<th width="30%"><b>商品</b></th>
							<th width="25%"><b>数量</b></th>
							<th width="25%"><b>单价</b></th>
							<th width="20%"><b>操作</b></th>
						    </tr>
						</thead>
						<tbody>
						<?php foreach ($cart as $k => $v) { ?>
							<tr id="cart_<?php echo $v['cart_id']?>">
								<td><?php echo $v['course_name'] ?></td>
								<td>1</td>
								<td class="price"><?php echo $v['price'] ?></td>
								<td><a class="delete" cart_id="<?php echo $v['cart_id'] ?>" href="javascript:void(0)">删除</a></td>
							</tr>
						<?php } ?>
						</tbody>
					</table>
					<div class="end-money-box">
						<div id="pay_amount" class="text-right">支付金额：<em class="red"><?php echo $price_amount ?>元</em></div>
						<div class="text-right btn-box">
						<form action="/index.php/course/order" method="get">
							<input id="submit_order" <?php if (!$price_amount>0) {echo "disabled" ;} ?> class="btn" type ="submit" value="&nbsp;&nbsp;&nbsp;&nbsp;去结算>>&nbsp;&nbsp;&nbsp;&nbsp;" type="button"></div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script>
	$(function(){
		$(".delete").click(function() {
			var cart_id = $(this).attr('cart_id');
				$.ajax({
					url: "<?php echo Url::to(['course/del-cart'])?>",
					type: 'get',
					data: {cart_id:cart_id},
					success:function(msg){
						if (msg) {
							history.go(0);
						}
					}
				})

		});

	})

</script>